/**
 * @author YinHang
 *多文件上传工具
 *基于oacore
 */
;(function () {
	/**
	 * fileList: 显示列表ul
	 * trigger: 上传触发按钮
	 * fileName: 文件名称
	 * descriptionName: 描述名称
	 */
	function MultiUpload(params)
	{
		this.form = params.fileList.parents("form:first");
		params.trigger.bind("click", function () {
			var file = $("<li><input type='file' name='"+ params.fileName +"' class='mu-file'/><span class='mu-description'>描述 :</span><input class='shadow nf-single-cell mu-description' maxlength='16' type='text' name='"+ params.descriptionName +"'/><a class='mu-remove'>删除</a></li>");
			file.appendTo(params.fileList)
			.find(".mu-remove")
			.bind("click", function () {
				$(this).parents("li").remove();
			});
			file.find(".mu-file:first").bind("change", function () {
				var orgValue = $(this).val();
				var nameStartIndex = orgValue.lastIndexOf('\\');
				if(nameStartIndex == -1)
					file.find(".file-name:first").html(orgValue);
				else
				{
					file.find(".file-name:first").html(orgValue.substring(nameStartIndex + 1, orgValue.length));
				}
			});
			return false;
		});
		return false;
	};
	
	oacore.Widget.MultiUpload = MultiUpload;
})();